<template>
  <div id="centerRight2">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span>
          <icon name="align-left" class="text-icon"></icon>
        </span>
        <span class="fs-xl text mx-2">生产阶段碳排放数据</span>
      </div>
      <div class="d-flex ai-center flex-column body-box">
        <dv-capsule-chart class="dv-cap-chart" :config="config"/>
        <centerRight2Chart1/>
      </div>
    </div>
  </div>
</template>

<script>
import centerRight2Chart1 from '@/components/echart/centerRight/centerRightChart'
import {getYearStageTotalCO2} from "@/api/carbon-manage/data";

export default {
  data() {
    return {
      config: {
        data: [
          {
            name: '燃料燃烧',
            value: 0
          },
          {
            name: '工业生产',
            value: 0
          },
          {
            name: '电力热力',
            value: 0
          },
          {
            name: '固碳产品',
            value: 0
          },
        ]
      }
    }
  },
  mounted() {
    this.loadData();
  },
  methods: {
    loadData() {
      getYearStageTotalCO2(new Date().getFullYear()).then(res => {
        this.config = {
          data: [
            {
              name: '燃料燃烧',
              value: res.data['燃料燃烧']
            },
            {
              name: '工业生产',
              value: res.data['工业生产']
            },
            {
              name: '电力热力',
              value: res.data['电力热力']
            },
            {
              name: '固碳产品',
              value: res.data['固碳产品']
            },
          ]
        }
      })
    },
  },
  components: {centerRight2Chart1}
}
</script>

<style lang="scss" scoped>
#centerRight2 {
  $box-height: 410px;
  $box-width: 340px;
  padding: 5px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;

  .bg-color-black {
    padding: 5px;
    height: $box-height;
    width: $box-width;
    border-radius: 10px;
  }

  .text {
    color: #c3cbde;
  }

  .body-box {
    border-radius: 10px;
    overflow: hidden;

    .dv-cap-chart {
      width: 100%;
      height: 160px;
    }
  }
}
</style>
